<html>
<head><meta charset="utf-8"><title>New blog post · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html">New blog post</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205983064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205983064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205983064">(Aug 05 2020 at 02:49)</a>:</h4>
<p><a href="https://blog.mozilla.org/nnethercote/2020/08/05/how-to-speed-up-the-rust-compiler-some-more-in-2020/">https://blog.mozilla.org/nnethercote/2020/08/05/how-to-speed-up-the-rust-compiler-some-more-in-2020/</a></p>



<a name="205985114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205985114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205985114">(Aug 05 2020 at 03:27)</a>:</h4>
<p><span class="user-mention" data-user-id="120989">@njn</span> is it you who writes these posts? Fwiw I love them. I always read them til the end, even tho I don't fully understand all the topics x3</p>



<a name="205986897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205986897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205986897">(Aug 05 2020 at 04:12)</a>:</h4>
<p>yep</p>



<a name="205988207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205988207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205988207">(Aug 05 2020 at 04:49)</a>:</h4>
<blockquote>
<p>Joshua Nelson added support for benchmarking rustdoc. This is good because rustdoc performance has received little attention in the past.</p>
</blockquote>
<p>IDK why but that second sentence cracks me up lmao</p>



<a name="205988216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205988216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205988216">(Aug 05 2020 at 04:49)</a>:</h4>
<p>"things were bad and everyone knew they were bad"</p>



<a name="205988224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205988224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205988224">(Aug 05 2020 at 04:49)</a>:</h4>
<p>Thanks for the mention :)</p>



<a name="205989848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/205989848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#205989848">(Aug 05 2020 at 05:33)</a>:</h4>
<p><span class="user-mention" data-user-id="120989">@njn</span> I see, thank you for making them!</p>



<a name="206017723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206017723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206017723">(Aug 05 2020 at 12:50)</a>:</h4>
<p><span class="user-mention" data-user-id="120989">@njn</span> <span class="user-mention" data-user-id="116122">@simulacrum</span> looking at the llvm-lines thing, do we pass <code>-Z symbol-mangling-version=v0</code> to avoid instances of the same generic function coalescing? or do we want instances to coalesce?</p>



<a name="206017747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206017747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206017747">(Aug 05 2020 at 12:50)</a>:</h4>
<p>not currently afaik</p>



<a name="206017772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206017772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206017772">(Aug 05 2020 at 12:51)</a>:</h4>
<p>it would probably be useful to support both</p>



<a name="206017992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206017992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206017992">(Aug 05 2020 at 12:53)</a>:</h4>
<p>probably requires changes to <code>cargo-llvm-lines</code> to count both, which might be tricky (I guess it could do a minimal amount of parsing on syntax? but you can't tell apart impls except by the impl disambiguator path in v0 mangling which is never shown in demangling, hmpf)</p>



<a name="206018082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206018082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206018082">(Aug 05 2020 at 12:54)</a>:</h4>
<p>this is where <span class="user-mention" data-user-id="124287">@mw</span>'s AST-like implementation of the mangling format would be more useful than the <code>rustc-demangle</code> implementation</p>



<a name="206090382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206090382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206090382">(Aug 05 2020 at 23:34)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> It invokes <code>cargo rustc</code>with <a href="https://github.com/dtolnay/cargo-llvm-lines/blob/master/src/main.rs#L338-L354">these options</a>. No <code>symbol-mangling-version</code>.</p>



<a name="206090393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206090393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206090393">(Aug 05 2020 at 23:35)</a>:</h4>
<p>As for what we want, presumably we want the output to reflect a normal build</p>



<a name="206102009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206102009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206102009">(Aug 06 2020 at 03:45)</a>:</h4>
<p><span class="user-mention" data-user-id="120989">@njn</span> the difference is that you can tell instances apart with v0 because the values for the generic parameters are mangled instead of just hashed</p>



<a name="206102050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206102050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206102050">(Aug 06 2020 at 03:46)</a>:</h4>
<p>it wouldn't change the amount of LLVM IR or anything like that</p>



<a name="206102786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206102786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206102786">(Aug 06 2020 at 04:05)</a>:</h4>
<p>@eddyb: so all the instantiations of <code>Vec::push</code>, for example, would show up in the list separately?</p>



<a name="206102839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206102839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206102839">(Aug 06 2020 at 04:06)</a>:</h4>
<p>That could be useful. Sometimes I see stuff like there are 100 instantiations of <code>Result::map_err</code> and I want to know "where are all these coming from?"</p>



<a name="206104185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206104185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206104185">(Aug 06 2020 at 04:39)</a>:</h4>
<p>yupp. the only tricky part if we did that would be if we wanted to see the same thing as today, but I'm not sure which is more useful overall</p>



<a name="206109636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206109636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206109636">(Aug 06 2020 at 06:49)</a>:</h4>
<p>-Z only works with Nightly, which is a clear limitation</p>



<a name="206113601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206113601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206113601">(Aug 06 2020 at 08:00)</a>:</h4>
<p>I was just looking at the output, very interesting. You really need both. The current output gives a good overview, and then you can use the <code>symbol-mangling-version</code> to dig into things.</p>



<a name="206113646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206113646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206113646">(Aug 06 2020 at 08:01)</a>:</h4>
<p>E.g. for the <code>cargo</code> benchmark, <code>Option::ok_or_else</code> accounts for 1.6% of LLVM IR generated in a debug build.</p>



<a name="206113773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206113773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206113773">(Aug 06 2020 at 08:02)</a>:</h4>
<p>With the detailed output and some detective work, I worked out that 80% of the 381 instances come from three functions in hashbrown: <code>new_uninitialized</code>, <code>reserve_rehash</code>, <code>try_with_capacity</code></p>



<a name="206113804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206113804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206113804">(Aug 06 2020 at 08:03)</a>:</h4>
<p>Tomorrow I will try changing those <code>ok_or_else</code> calls to just vanilla <code>match</code>es, see if it makes a measurable improvement in compile time</p>



<a name="206117099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206117099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206117099">(Aug 06 2020 at 08:48)</a>:</h4>
<p>you can get both from the mangled data (harder), or even the demangled version (if you don't care about telling apart trait impls), the latter mostly by removing matching &lt;...&gt;</p>



<a name="206117245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206117245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206117245">(Aug 06 2020 at 08:50)</a>:</h4>
<p>for <a href="http://perf.rust-lang.org">perf.rust-lang.org</a> I doubt <code>-Z</code> flags are a problem but I'll let <span class="user-mention" data-user-id="116122">@simulacrum</span> be the judge of that</p>



<a name="206117612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206117612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206117612">(Aug 06 2020 at 08:54)</a>:</h4>
<p>cargo-llvm-lines is a general purpose tool used in other places. But an option would be reasonable</p>



<a name="206118908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206118908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206118908">(Aug 06 2020 at 09:11)</a>:</h4>
<p>I'd like to print more info from the mono item graph to show such causes of monomorphizations like this (and am slowly working on it)</p>



<a name="206120058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206120058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206120058">(Aug 06 2020 at 09:27)</a>:</h4>
<p>oh and that would solve the problem of matching the LLVM IR to the instantiations</p>



<a name="206120154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206120154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206120154">(Aug 06 2020 at 09:28)</a>:</h4>
<p><span class="user-mention" data-user-id="120989">@njn</span> tbf I was imagining passing the arguments through, kind of like <code>cargo rustc -- ...</code> but that wouldn't affect code already compiled in dependencies</p>



<a name="206120184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/New%20blog%20post/near/206120184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/New.20blog.20post.html#206120184">(Aug 06 2020 at 09:29)</a>:</h4>
<p>(i.e. I was imagining we could do this without modifying <code>cargo-llvm-lines</code> at all)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>